var express = require("express");
var router = express.Router();

const JWT = require("../utils/jwt");

router.get("/create", (req, res) => {
  const token = JWT.createToken(
    { name: "chenchenke", id: "123123" },
    1000 * 60 * 60
  );
  res.send(token);
});

router.get("/verify", (req, res) => {
  const { token } = req.query;
  const data = JWT.verifyToken(token);
  const data1 = JWT.verifyToken(token.split(" ")[1]);
  console.log(req.query, "req");
  // eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiY2hlbmNoZW5rZSIsImlkIjoiMTIzMTIzIiwiaWF0IjoxNzA5MjAyNjI2LCJleHAiOjE3MTI4MDI2MjZ9.4X8_yoXyyN3FmJLAa648qGRlUWmbclp-mUPbf8qFwHY
  res.send(data);
});

module.exports = router;
